<template>
	<view class="white">
		<u-navbar :is-back="false" :border-bottom="false" :background="{ background: '#fff' }">
			<view class="slot-wrap flex align-center">
				<text class="cuIcon-back" @click="Back"></text>
				{{title}}
			</view>
		</u-navbar>
		<view class="main" v-for="(item,index) in list" :key="index"  @click="multiRedirect('/pages/details/details?id='+item.id)">
			<image :src="item.cover_img" mode="aspectFill"></image>
			<view class="u-flex justify-between">
				<view class="u-flex-1">
					<view class="u-font-30 text-bold">
						{{item.name}}
					</view>
					<view class="u-font-24">
						{{item.intro}}
					</view>
				</view>
				<view class="cu-btn round bg-orange">
					查看
				</view>
			</view>
		</view>
		
		<view class="icon">
			<button class="cu-btn" style="padding: 0;border-radius: 50%;"  @click="makePhoneCall(custom_tel)">
				<image src="../../static/images/icon1.png" mode="aspectFill"></image>
			</button>
			<navigator open-type="switchTab" url="/pages/cart/cart" class="">
				<image src="../../static/images/icon2.png" mode="aspectFill"></image>
			</navigator>
			<button class="cu-btn" style="margin-top: 20rpx;padding: 0;border-radius: 50%;" type="default" open-type="share">
				<image src="../../static/images/icon3.png" mode="aspectFill"></image>
			</button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				title:"",
				custom_tel:'',
				
				listQuery:{
					keyword: '',
					is_view: '',
					is_child: '',
					is_activity: '',
					cid: '',
					ct_id: '',
					is_up: '',
					page: 1,
				},			
				list: [],
				total_page:false,
			}
		},
		onLoad(options) {
			this.title = options.title||""
			this.listQuery.cid = options.cid || 0;
			this.getBaseInfo();
			this._initData(true);
		},
		onReachBottom() {
			console.log('-----onReachBottom')
			if(this.total_page!==false && this.listQuery.page<=this.total_page){
				this._initData();
			}
		},
		methods: {
			getBaseInfo(){
				this.$u.http.post('/api/index/defInfo', {
					type:'base_info'
				}).then(({ data }) => {
					this.custom_tel = data.custom_tel||''
					
				}).catch(v => {
					
				});
			},
			_initData(is_reset) {
				if (is_reset === true) {
					this.listQuery.page=1
					this.total_page = false;
					this.list = [];
				}
				this.$u.http.post('/api/course/lists',this.listQuery).then(({
					data
				}) => {
					this.list = this.list.concat(data.list || [])
					this.listQuery.page++
					this.total_page = data.total_page || 0		
				});
			},
			Back() {
				uni.navigateBack({});
			},
			
		}
	}
</script>

<style lang="scss">
	.main{
		padding: 35rpx 30rpx;
		image{
			width: 690rpx;
			height: 409rpx;
			border-radius: 10rpx;
		}
		.u-flex {
			margin: 30rpx 20rpx 0;
		
			.u-font-30 {
				color: #333;
				margin-right: 10rpx;
				overflow: hidden;
				text-overflow: ellipsis;
				display: -webkit-box;
				-webkit-box-orient: vertical;
				-webkit-line-clamp: 2;
			}
		
			.u-font-24 {
				color: #999;
				margin-top: 20rpx;
				margin-right: 10rpx;
			}
		
			.cu-btn {
				width: 113rpx;
				height: 60rpx;
				font-size: 24rpx;
			}
		}
	}
	.icon{
		position: fixed;
		bottom: 80rpx;
		right: 30rpx;
		image{
			width: 100rpx;
			height: 100rpx;
			border-radius: 50%;
			margin-top: 25rpx;
			box-shadow: 0rpx 0rpx 10rpx #888888;
		}
		
	}
</style>
